package com.xiaofan.config;

import com.alibaba.druid.pool.DruidDataSource;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 晓帆
 * @version 1.0
 **/
@Data
@Configuration
@EnableConfigurationProperties(DbPropertites.class)
public class ConfigDB {
    public ConfigDB(DbPropertites dbPropertites) {
        this.dbPropertites = dbPropertites;
    }

    DbPropertites dbPropertites;

@Bean
    public DruidDataSource get(){
    DruidDataSource dataSource = new DruidDataSource();
    dataSource.setUrl(dbPropertites.getUrl());
    return dataSource;
}
}
